//
//  FenLeiXiangQing_ViewController.m
//  OpenYooxi_IOS
//
//  Created by YeahYes on 15/3/19.
//  Copyright (c) 2015年 com.ivyvi.ee. All rights reserved.
//

#import "FenLeiXiangQing_ViewController.h"
#import "UIViewExt.h"
#import "Shaixuan_TableViewCell.h"
#import "TianXieDingDan_ViewController.h"

static NSString *identify = @"Cell";


@interface FenLeiXiangQing_ViewController ()

@end

@implementation FenLeiXiangQing_ViewController


- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self initNavigationBar];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //自定义uinavigationbar
    [self initNavigationBar];
    
    
    
    _Shaixuantableview.dataSource = self;
    _Shaixuantableview.delegate = self;
    //    _ShouChangTableview.pagingEnabled = YES;
    _Shaixuantableview.separatorStyle = UITableViewCellSeparatorStyleNone;
    //取消tableview右侧的滑动条
    _Shaixuantableview.showsVerticalScrollIndicator = NO;
    _Shaixuantableview.backgroundColor = [UIColor whiteColor];
    
    
    //注册uitableviewcell
    UINib *nib = [UINib nibWithNibName:@"Shaixuan_TableViewCell" bundle:[NSBundle mainBundle]];
    [_Shaixuantableview registerNib:nib forCellReuseIdentifier:identify];

}



#pragma mark -- 自定义uinavigationbar
- (void)initNavigationBar{
    [self.navigationController setNavigationBarHidden:YES];
    
    
    UINavigationBar *bar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 88)];
    
    
    UIButton *left = [UIButton buttonWithType:UIButtonTypeCustom];
    
    left.frame = CGRectMake(16, 31, 10, 20);
    [left setImage:[UIImage imageNamed:@"2_03"]
                 forState:UIControlStateNormal];
    [left addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    [bar addSubview:left];
    
    
    //搜索框的创建
    UIView *navview = [[UIView alloc] initWithFrame:CGRectMake(0, 24, kScreenWidth-56, 34)];
    navview.layer.cornerRadius = 4;
    navview.layer.masksToBounds = YES;
    navview.layer.borderColor = UIColorFromRGB(0xE5E5E5).CGColor;
    navview.layer.borderWidth = 1;
    UIImageView *suoimg = [[UIImageView alloc] initWithFrame:CGRectMake(8, 8, 18, 18)];
    suoimg.image = [UIImage imageNamed:@"9_03"];
    [navview addSubview:suoimg];


    

    UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(34, 2, kScreenWidth-90, 30)];
    textField.borderStyle = UITextBorderStyleNone;
    textField.font = [UIFont systemFontOfSize:13];
    textField.textColor = [UIColor blackColor];
    textField.placeholder = @"搜索您感兴趣的商品";
    [navview addSubview:textField];
    navview.backgroundColor = [UIColor whiteColor];
    
    navview.left = left.right+10;
    [bar addSubview:navview];

    
    UIView *xiaView = [[UIView alloc] initWithFrame:CGRectMake(0, 66, kScreenWidth, 22)];
    xiaView.backgroundColor = [UIColor clearColor];
    [bar addSubview:xiaView];
    
    NSArray *buttonImg = @[@"9_033",@"9_04",@"9_05",@"9_06",];
    
    for(NSInteger i=0;i<buttonImg.count;i++){
        UIButton *buttonx = [UIButton buttonWithType:UIButtonTypeCustom];
        buttonx.frame = CGRectMake((kScreenWidth/4)*i, 0, kScreenWidth/4, 22);
        [buttonx setImage:[UIImage imageNamed:buttonImg[i]] forState:UIControlStateNormal];
        buttonx.tag =i;
        [buttonx addTarget:self action:@selector(zongheclick:) forControlEvents:UIControlEventTouchUpInside];
        [buttonx setAdjustsImageWhenHighlighted:NO];
        [xiaView addSubview:buttonx];
    }
    
    
    [self.view addSubview:bar];
}


- (void)zongheclick:(UIButton *)button{

    MyLog(@"%ld",(long)button.tag);
}

#pragma mark - UITableView delegate 设置单元格高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    return 100;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 6;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    Shaixuan_TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identify forIndexPath:indexPath];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    TianXieDingDan_ViewController *tianxiedingdan = [[TianXieDingDan_ViewController alloc] initWithNibName:@"TianXieDingDan_ViewController" bundle:nil];
    [self.navigationController pushViewController:tianxiedingdan animated:YES];

}




- (void)back{
    [self.navigationController popViewControllerAnimated:YES];
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
